<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="text" id="input" />
  <div id="app"></div>
  <script>
    let obj = {}
    Object.defineProperty(obj, "name", {
      // 取值
      get: function() {},
      // 设置值
      set: function(val) {
        document.getElementById('app').innerHTML = val
      }
    })
    document.getElementById('input').addEventListener('keyup', function() {
      obj.name = event.target.value
    })

    // 订阅器模型
    let Dep = {
      clientList: {},
      listren: function(key, fn) {
        (this.clientList[key] || (this.clientList[key] = [])).push(fn)
      },
      trigger: function() {
        let key = Array.prototype.shift.call(arguments),
        fns = this.clientList[key]
        if (!fns || fns.length === 0) {
          return false
        }
      }
    }
  </script>
</body>

</html>